package co.com.mobileandbusiness.alarmas.persistencia.dao.common;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import co.com.mobileandbusiness.alarmas.persistencia.constants.PersistenciaConstants;
import co.com.mobileandbusiness.alarmas.persistencia.dao.IDAO;

public class SinglentonSpring {
	
	
	private static SinglentonSpring instance = null;
	
	private ClassPathXmlApplicationContext ctx = null;
	
	private SinglentonSpring(){
		init();
	}
	
	private void init() {
		if(ctx == null)
			ctx = new ClassPathXmlApplicationContext("/co/com/mobileandbusiness/config/applicationContext-hibernate.xml");
	}

	public static SinglentonSpring getInstance(){
		if(instance == null){
			return new SinglentonSpring();
		}		
		return instance;
	}
	
	public IDAO getDAO(){
		return (IDAO)ctx.getBean(PersistenciaConstants.DAO);
	}
	
	
	
}
